<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function arr(nums) {
      let total = 0;
      let k = 0;
      for (let a of nums) {
        if (a % 6 === 0) {
          total += a;
          k++;
        }
      }
      return k > 0 ? Math.floor(total / k) : 0;
    };
    console.log(arr([1, 3, 6, 10, 12, 15]));
  </script>
</body>

</html>